<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <div th:include="base-libs :: base-libs" />
    <title>家庭医生签约台账—新增</title>

    <script th:src="@{/tbxt/js/easyui_editModel.js}"></script>
    <script th:src="@{/tbxt/js/TzUtils.js}"></script>

    <style>
        .spanBtn{
            font-weight: bold;
            color: blue;
            cursor:pointer;
        }
    </style>
    <script>
        var $addTb;
        $(function(){
            $addTb = $("#addTb");
            initView();
            initData();
        })

        function initView(){

            /* 模板表格 */
            $("#modelTb").datagrid({
                fitColumns: true,
                fit:true,
                scrollbarSize:10,
                rownumbers: true,
                columns : [[
                    {field : "QYSJ",title : "2017-07-02",width:90,align:'center'},
                    {field : "XM",title : "张三",width:80,align:'center'},
                    {field : "SFZH",title : "411722197508214024",width:160,align:'left'},
                    {field : "SJHM",title : "13567890987",width:100,align:'left'},
                    {field : "JTZZ",title : "江西省南昌市东湖区豫章",width:180,align:'left'},
                    {field : "RQFL",title : "高血压，孕产妇",width:130,align:'center'},
                    {field : "QYTD",title : "沈舒团队",width:100,align:'center'},
                    {field : "QYFWB",title : "基础服务包，高血压基础",width:180,align:'left'},
                    {field : "cz",title : "",width:80,align:'center'}
                ]]
            });

            /** 添加表格  */
            $addTb.datagrid({
                striped : true,
                clickToSelect: true,
                fitColumns: true,
                singleSelect: true,
                fit:true,
                scrollbarSize:10,
                rownumbers: true,
                columns : [[
                    {field : "QYSJ",title : "签约时间",width:90,align:'center',
                        editor:{
                            type: "laydate",
                            options:{
                                label: '签约时间',
                                validateProxy:'notNull D10',
                            }
                        }
                    },
                    {field : "XM",title : "签约居民",width:80,align:'center',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '签约居民',
                                length:32,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "SFZH",title : "证件号码",width:160,align:'left',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '证件号码',
                                length:32,
                                validateProxy:'notNull idCard length',
                            }
                        }
                    },
                    {field : "SJHM",title : "手机号码",width:100,align:'left',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '手机号码',
                                length:32,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "JTZZ",title : "家庭住址",width:180,align:'left',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '家庭住址',
                                length:128,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "RQFL",title : "人群分类",width:130,align:'center',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '人群分类',
                                length:64,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "QYTD",title : "签约团队",width:100,align:'center',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '签约团队',
                                length:32,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "QYFWB",title : "签约服务包",width:180,align:'left',
                        editor:{
                            type: "quickTextValidate",
                            options:{
                                label: '签约服务包',
                                length:128,
                                validateProxy:'notNull length',
                            }
                        }
                    },
                    {field : "cz",title : "操作",width:80,align:'center', formatter:function(value,row,index){
                        return TzUtils.formatZcBtn(index);
                    }}
                ]],
                onClickRow : function(rowIndex, row){
                    var editRowNum = $(this).data("editRowNum");
                    if(!StringUtils.isEmpty(editRowNum) && rowIndex != editRowNum){
                        //不做数据验证（避免和添加按钮中的验证重复）
                        $(this).datagrid('endEdit', editRowNum).datagrid('beginEdit', rowIndex)
                            .data("editRowNum",rowIndex);
                    }
                },
            });

            /** 添加一行  */
            $("body").on("click",".btnTj",function(){
                TzUtils.addRow();
            })

            /** 删除一行  */
            $("body").on("click",".btnSc",function(){
                TzUtils.deleteRow();
            })

            /** 提交 */
            $("#btnTj").click(function () {
                TzUtils.save(contextRoot + "jtysqytz/save");
            })

            /** 返回 */
            $("#btnFh").click(function () {
                $.QuickUrlUtils.redirectUrl("index.html");
            })

            /** 导入 */
            $("#btnDr").click(function () {
                TzUtils.openImpotView(contextRoot + 'jtysqytz/import.html');
            })

            /** 下载模板 */
            $("#btnXzmb").click(function () {
                $("#formXzmb").submit();
            })

            //改变样例表格样式
            TzUtils.format_modelTbStyle();
        }

        function initData(){
            TzUtils.addRow(); //默认添加一行
        }
    </script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height:80px;border:0;overflow: hidden">
    <h3 style="font-size:14px;padding: 15px 0px 3px 15px;">
        <span id="haha"></span>
        <span style="font-weight: bold;letter-spacing:0.5px">请按以下格式新增家庭医生签约记录：</span>
        <button id="btnXzmb" class="btn btn-info" type="button" style="float:right;margin-right:35px;margin-left:0px;position:relative;top:-8px">下载模板</button>
        <button id="btnDr" class="btn btn-info" type="button" style="float:right;margin-right:8px;position:relative;top:-8px">导入</button>
    </h3>
    <table id="modelTb"></table>
</div>
<div region="center" border="false">
    <table id="addTb"></table>
</div>
<div region="south" style="height:40px;line-height:40px;border:0;border-top:1px solid #ddd;text-align: center;overflow: hidden">
    <button id="btnTj" class="btn btn-info" type="button">提交</button>
    <button id="btnFh" class="btn btn-info" type="button">返回</button>
</div>

<form id="formXzmb" action="downExcelModel" method="post" enctype="multipart/form-data"></form>
<form id="formDr" action="parseExcalData" method="post" enctype="multipart/form-data" style="opacity: 0;display: none">
    <input id="fileField" type="file" name="fileField"  />
</form>

</body>
</html>